package com.cos.lession77;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.event.SyncReadListener;
import com.cos.lession77.dao.EmpMapper;
import com.cos.lession77.entity.Emp;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author: COS
 * @time: 2022/10/10 17:28
 * @description:
 */
public class Demo extends Lession77ApplicationTests{

    @Autowired
    private EmpMapper empMapper;


    @Test
    public void t1(){
        List<Emp> list = empMapper.getAll();
        EasyExcel.write("./emp.xlsx",Emp.class)
                .sheet("员工信息")
                .doWrite(list);
    }

    @Test
    public void t2(){
        List<Emp> objects = EasyExcel.read("./emp.xlsx", Emp.class, new SyncReadListener()).doReadAllSync();
        objects.stream().forEach(System.out::println);
    }
}
